package cool.zhoujie.address.db;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import cool.zhoujie.address.MyApplication;

@Database(entities = {Address.class}, exportSchema = false, version = 1)
public abstract class AddressDatabase extends RoomDatabase {

    public abstract AddressDao mAddressDao();

    private static volatile AddressDatabase INSTANCE;

    public static AddressDatabase getInstance() {
        if (INSTANCE == null) {
            synchronized (Address.class) {
                INSTANCE = Room.databaseBuilder(MyApplication.getContext(), AddressDatabase.class
                        , "address.db")
                        .allowMainThreadQueries()
                        .build();
            }
        }
        return INSTANCE;
    }
}
